package cn.zhoushengdao.bingwallpaper

data class WallpaperData(
    val date: String,
    val imageUrl: String,
    val copyright: String,
    val searchUrl: String,
    val title: String,
    val description: String,
    val headline: String,
    val quizUrl: String,
    val mapImage: String,
    val mapUrl: String,
) {
    fun getFullImageUrl(screenWidth: Int, screenHeight: Int): String {
        val aspectRatio = screenWidth.toDouble() / screenHeight

        val targetRatio = 9.0 / 16
        val ratioThreshold = 0.3 // 30% 容差
        val isVerticalScreen =
            aspectRatio in (targetRatio * (1 - ratioThreshold))..(targetRatio * (1 + ratioThreshold))

        val processedUrl = if (isVerticalScreen) {
            imageUrl.replace("UHD", "1080x1920", ignoreCase = true)
        } else {
            imageUrl
        }

        return "$processedUrl&w=$screenWidth&h=$screenHeight&rs=1&c=4"
    }
}
